package com.etbsms.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import com.etbsms.dao.IRoleDAO;
import com.etbsms.domain.Role;
import com.etbsms.service.IRoleService;
import com.etbsms.util.Constants;

@Service
@Component("roleService")
public class RoleServiceImpl implements IRoleService{
	
	@Autowired
	private IRoleDAO roleDAO;
	
	@Override
	public void init() {		
		
		Role role = new Role();
		role.setName(Constants.ROLE_ROOT);
		role.setDescription("管理者");
		role.setSort(1);
		role.setEnabled(true);
		roleDAO.save(role);
		
		role.setName(Constants.ROLE_KEYR);
		role.setDescription("輸入者");
		role.setSort(2);
		roleDAO.save(role);
		
		role.setName(Constants.ROLE_INTR);
		role.setDescription("研析者");
		role.setSort(3);
		roleDAO.save(role);
	}

	@Override
	public List<Role> getAll() {
		// TODO Auto-generated method stub
		return roleDAO.getAll();
	}

	@Override
	public Role get(String role) {
		// TODO Auto-generated method stub
		return roleDAO.get(role);
	}
}
